/*
 * common.h
 *
 *  Created on: 20.07.2013
 *      Author: SpirTanol
 */

#ifndef COMMON_H_
#define COMMON_H_

typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short int u16;
typedef signed short int s16;
typedef unsigned int u32;
typedef signed int longs32;
typedef unsigned long int u64;
typedef signed long int s64;

#define BIT(x) (1<<(x))

#define BYTE0(x) *(((u8*)&x)+0)
#define BYTE1(x) *(((u8*)&x)+1)
#define BYTE2(x) *(((u8*)&x)+2)
#define BYTE3(x) *(((u8*)&x)+3)

#define WORD0(x) *(((u16*)&x)+0)
#define WORD1(x) *(((u16*)&x)+1)

//------------------------------------
//! binary constants definition macro
#define _bitset(bits)\
  ((byte)(\
  (bits%010)|\
  (bits/010%010)<<1|\
  (bits/0100%010)<<2|\
  (bits/01000%010)<<3|\
  (bits/010000%010)<<4|\
  (bits/0100000%010)<<5|\
  (bits/01000000%010)<<6|\
  (bits/010000000%010)<<7))

#define BINARY(bits) _bitset(0##bits)
//------------------------------------

#endif /* COMMON_H_ */
